﻿@inject IDataCacheService _dataCacheService
@if (Model.MainState == EditState.Preview)
{
    <CnGalWebSite.Shared.MasaComponent.Shared.Editors.Buttons.RevokeButton Url="@("/entries/EditMain/" + Model.Id)" ExamineType="Operation.EstablishMain" OnClickRevoke="OnRevoke" Class="ms-4 me-4" />
}
<CnGalWebSite.Shared.MasaComponent.Shared.MaterialDesigns.MDMainInfoCard Name="@Model.Name" Thumbnail="Model.Type== EntryType.Role||Model.Type== EntryType.Staff" Image="@(Model.Type== EntryType.Role||Model.Type== EntryType.Staff?Model.Thumbnail:Model.MainPicture)"
                                                                         BriefIntroduction="@Model.BriefIntroduction" Class="entry-card-default main-card" Small="ForceSmall">
    <ChildContent>
        @if (Model.Type == EntryType.Game)
        {
            <div class="groups-card">
                @if (Model.ProductionGroups.Count > 0)
                {
                    <div>
                        <CnGalWebSite.Shared.MasaComponent.Shared.Buttons.OutlineButton IsTitile="true" Text="制作组"/>

                        @foreach (var temp in Model.ProductionGroups)
                        {
                            <CnGalWebSite.Shared.MasaComponent.Shared.Buttons.OutlineButton IsTitile="false" Text="@temp.DisplayName" IsShowExistTag="Model.IsEdit" EntryId="temp.Id" ItemProp="author" ItemType="http://schema.org/Organization" />
                        }
                    </div>


                }
                @if (Model.Publishers.Count > 0)
                {
                    <div>
                        <CnGalWebSite.Shared.MasaComponent.Shared.Buttons.OutlineButton IsTitile="true" Text="发行商"/>

                        @foreach (var temp in Model.Publishers)
                        {
                            <CnGalWebSite.Shared.MasaComponent.Shared.Buttons.OutlineButton IsTitile="false" Text="@temp.DisplayName" IsShowExistTag="Model.IsEdit" EntryId="temp.Id" ItemProp="publisher" ItemType="http://schema.org/Organization" />
                        }

                    </div>
                }
            </div>

        }
    </ChildContent>
    <ButtonContent>
        @if (HiddenButton == false)
        {
            <CnGalWebSite.Components.Containers.MiniModeContainer>
                <div class="options-card">
                    <CnGalWebSite.Shared.MasaComponent.Shared.Buttons.FavoriteButton Id="Model.Id" Type="FavoriteObjectType.Entry" />

                    <CnGalWebSite.Shared.MasaComponent.Shared.Editors.Buttons.EditButton Type="ExaminedNormalListModelType.Entry" Id="Model.Id" ShowPerfection="Model.Type==EntryType.Game" @bind-IsHidden="@Model.IsHidden" IsEdit="Model.IsEdit" IsEditChanged="OnPreEdit" />
                    @if (ToolHelper.IsMaui)
                    {
                        <CnGalWebSite.Shared.MasaComponent.Shared.Buttons.ShareButton Title="@(Model.Type.GetDisplayName()+" - "+Model.Name)" Text="@($"【{Model.Type.GetDisplayName()}】《{Model.Name}》\n{Model.BriefIntroduction}")" />
                    }
                </div>
            </CnGalWebSite.Components.Containers.MiniModeContainer>

        }
    </ButtonContent>
</CnGalWebSite.Shared.MasaComponent.Shared.MaterialDesigns.MDMainInfoCard>

@code {
    [Parameter]
    public EntryIndexViewModel Model { get; set; }
    [Parameter]
    public bool HiddenButton { get; set; }
    [Parameter]
    public bool ForceSmall { get; set; }

    [Parameter]
    public EventCallback<Operation> OnRevoke { get; set; }
    [Parameter]
    public EventCallback<bool> OnPreEdit { get; set; }
}
